// Created by WXX on 2021/10/23 16:28
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    vector<vector<int>> ans;
    vector<int> path;
    int k;

    vector<vector<int>> combine(int n, int _k) {

        k = _k;
        path.resize(k);
        dfs(n, 0, 1);
        return ans;
    }

    // 位置u可以放置[start...]里的数据
    void dfs(int n, int u, int start) {
        if (u == k) {
            ans.push_back(path);
            return;
        }

        for (int i = start; i <= n; i++) {
            path[u] = i;
            dfs(n, u + 1, i + 1);
        }
    }
};

void OutputBasicArray2D1(vector<vector<int>> nums) {

    cout << "[";
    for (int i = 0; i < nums.size(); i++) {
        cout << "[";
        for (int j = 0; j < nums[i].size(); j++) {
            cout << nums[i][j];
            if (j != nums[i].size() - 1) cout << ", ";
        }
        cout << "]";
        if (i != nums.size() - 1) cout << ", ";
    }
    cout << "]" << endl;
}

int main() {

    OutputBasicArray2D1(Solution().combine(4, 2));

    return 0;
}
